using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GeoFramework.Examples
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        #region Code for Clicking Example Links

        private void CloseOpenForms()
        {
            // Close any child forms
            foreach (Form existingForm in MdiChildren)
            {
                existingForm.Close();
                existingForm.Dispose();
            }
        }

        private void ShowForm(Form form)
        {
            // Then open the new one
            form.MdiParent = this;
            form.BackColor = Color.White;
            form.WindowState = FormWindowState.Normal;
            form.MaximizeBox = false;
            form.MinimizeBox = false;
            form.Show();

            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ConnectingAndDisconnectingLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new ConnectingAndDisconnectingForm());
        }

        private void CurrentLocationLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new LiveDataForm());
        }

        private void DetectingDevicesLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new DetectingDevicesForm());
        }

        private void AsynchronousDetectionLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new AsynchronousDetectingDevicesForm());
        }

        private void MonitoringDeviceDetectionLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new MonitoringDetectingDevicesForm());
        }

        private void ParsingStringsLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new StringParsingForm());
        }

        private void CompassLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new CompassForm());
        }

        private void ControlPerformanceTuningLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new ControlPerformanceTuningForm());
        }

        private void linkLabel9_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new AltimeterForm());
        }

        private void SpeedometerLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new SpeedometerForm());
        }

        private void SatelliteViewerLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new SatelliteViewerWithSignalBarForm());
        }

        private void CustomDeviceEmulatorsLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new CustomDeviceEmulatorForm());
        }

        private void WorkingWithEmulatorsLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new WorkingWithEmulatorsForm());
        }

        private void CalculatingBearingLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new CalculateBearingForm());
        }

        private void CalculatingDistanceLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new CalculateDistanceForm());
        }

        private void SynchronizingTheClockLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new SynchronizingTheClockForm());
        }

        private void LoggingGpsDataLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new LoggingGpsDataForm());
        }

        private void AsynchronousDeviceDetectionLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new AsynchronousDetectingDevicesForm());
        }

        private void UnderstandingPrecisionLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CloseOpenForms();
            ShowForm(new UnderstandingPrecisionForm());
        }

        #endregion
    }
}